#ifndef __SCOPED_MUTEX_H__
#define __SCOPED_MUTEX_H__

#include "rw_mutex.hpp"
namespace vpm
{
	namespace utils
	{
		class ScopedMutex
		{
		public:
			ScopedMutex(RWMutex & rwmutex):m_rwMutex(rwmutex)
			{
				m_rwMutex.lock(); 
			}
			~ScopedMutex()
			{
				m_rwMutex.unlock(); 
			}

			RWMutex & m_rwMutex; 
		};

		class ScopedReadMutex
		{
		public:
			ScopedReadMutex(RWMutex & rwmutex):m_rwMutex(rwmutex)
			{
				m_rwMutex.lock_read(); 
			}
			~ScopedReadMutex()
			{
				m_rwMutex.unlock(); 
			}

			RWMutex & m_rwMutex; 
		};

		class ScopedWriteMutex
		{
		public:
			ScopedWriteMutex(RWMutex & rwmutex):m_rwMutex(rwmutex)
			{
				m_rwMutex.lock_write(); 
			}
			~ScopedWriteMutex()
			{
				m_rwMutex.unlock(); 
			}

			RWMutex & m_rwMutex; 
		};


	}
}


#endif // 

